package com.zz.io;

import java.io.*;

public class Test6 {
    public static void main(String args[]){
        try(
                InputStream is = new FileInputStream("opp-app1\\src\\data\\test2.txt");
                //1.定义一个字节缓冲输入流包装原始的字节输入流
                //原始缓冲池大小为8KB=8192B，可以设置缓冲池大小
                InputStream bis = new BufferedInputStream(is, 8192*2);
                OutputStream os = new FileOutputStream("opp-app1\\src\\data\\test3.txt");
                //2.定义一个字节缓冲输出流包装原始的字节输入流
                OutputStream bos = new BufferedOutputStream(os, 8192 * 2)
                ){
                    byte[] buffer = new byte[1024];
                    int len;
                    while((len = bis.read(buffer))!= -1){
                        bos.write(buffer, 0, len);
                    }
                    System.out.print(new String(buffer));
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
